import Vue from 'vue'
import Router from 'vue-router'
import SCart from '@/components/ShoppingCart/shoppingCart'
import Payment from '@/components/ShoppingCart/payment'
import Login from '@/components/Login/Login'
import Register from '@/components/Login/Register'
import Success from '@/components/ShoppingCart/success'

const originalPush = Router.prototype.push

Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(Router)

export default new Router({
  routes: [
    {path: '/', redirect: 'shoppingcart'}, 
    // {
    //   path: '/**',
    //   name: 'UserCenter',
    //   component: UserCenter,
    //   children: []
    // },
    {
      path: '/register',
      name: "Register",
      component: Register
    },
    {
      path: '/shoppingcart',
      name: "SCart",
      component: SCart
    },
    {
      path: '/payment',
      name: "Payment",
      component: Payment
    },
    {
      path: '/login',
      name: "Login",
      component: Login
    },
    {
      path: '/success',
      name: "Success",
      component: Success
    },
  ]
})
